import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '安全制度编码',
    align: "center",
    sorter: true,
    dataIndex: 'number'
  },
  {
    title: '版本号',
    align: "center",
    sorter: true,
    dataIndex: 'version'
  },
  {
    title: '安全制度名称',
    align: "center",
    dataIndex: 'name'
  },
  {
    title: '安全制度分类',
    align: "center",
    dataIndex: 'type_dictText'
  },
  {
    title: '所属部门',
    align: "center",
    dataIndex: 'subDepart_dictText'
  },
  {
    title: '发布日期',
    align: "center",
    sorter: true,
    dataIndex: 'releaseDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '是否现行',
    align: "center",
    dataIndex: 'currentOrNot_dictText'
  },
  {
    title: '启用日期',
    align: "center",
    sorter: true,
    dataIndex: 'startDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '适用部门',
    align: "center",
    dataIndex: 'applicableDepart_dictText'
  },
  {
    title: '制度内容',
    align: "center",
    dataIndex: 'content',
  },
  {
    title: '说明',
    align: "center",
    dataIndex: 'remarks'
  },
  {
    title: '制度相关附件',
    align: "center",
    dataIndex: 'doc',
  },
  {
    title: '编制人',
    align: "center",
    dataIndex: 'organizer_dictText'
  },
  {
    title: '评审日期',
    align: "center",
    sorter: true,
    dataIndex: 'reviewDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '评审人',
    align: "center",
    dataIndex: 'assessor_dictText'
  },
  {
    title: '参评人员',
    align: "center",
    dataIndex: 'evaluator_dictText'
  },
  {
    title: '评审相关附件',
    align: "center",
    dataIndex: 'reviewDoc',
  },
  {
    title: '评审意见',
    align: "center",
    dataIndex: 'reviewComments'
  },
  {
    title: '状态',
    align: "center",
    dataIndex: 'deleted_dictText'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "安全制度名称",
    field: 'name',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "安全制度分类",
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "safetySystemType"
    },
    //colProps: {span: 6},
  },
  {
    label: "发布日期",
    field: "releaseDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "是否现行",
    field: 'currentOrNot',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yn"
    },
    //colProps: {span: 6},
  },
  {
    label: "评审日期",
    field: "reviewDate",
    component: 'RangePicker',
    //colProps: {span: 6},
  },
  {
    label: "评审人",
    field: 'assessor',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "参评人员",
    field: 'evaluator',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '安全制度编码',
    field: 'number',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入安全制度编码!'},
             ];
    },
  },
  {
    label: '版本号',
    field: 'version',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入版本号!'},
             ];
    },
  },
  {
    label: '安全制度名称',
    field: 'name',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入安全制度名称!'},
             ];
    },
  },
  {
    label: '安全制度分类',
    field: 'type',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "safetySystemType"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入安全制度分类!'},
             ];
    },
  },
  {
    label: '所属部门',
    field: 'subDepart',
    component: 'JSelectDept',
  },
  {
    label: '发布日期',
    field: 'releaseDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入发布日期!'},
             ];
    },
  },
  {
    label: '是否现行',
    field: 'currentOrNot',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "yn"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入是否现行!'},
             ];
    },
  },
  {
    label: '启用日期',
    field: 'startDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入启用日期!'},
             ];
    },
  },
  {
    label: '适用部门',
    field: 'applicableDepart',
    component: 'JSelectDept',
  },
  {
    label: '制度内容',
    field: 'content',
    component: 'JEditor',
  },
  {
    label: '说明',
    field: 'remarks',
    component: 'InputTextArea',
  },
  {
    label: '制度相关附件',
    field: 'doc',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '编制人',
    field: 'organizer',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入编制人!'},
             ];
    },
  },
  {
    label: '评审日期',
    field: 'reviewDate',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入评审日期!'},
             ];
    },
  },
  {
    label: '评审人',
    field: 'assessor',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入评审人!'},
             ];
    },
  },
  {
    label: '参评人员',
    field: 'evaluator',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
  },
  {
    label: '评审相关附件',
    field: 'reviewDoc',
    component: 'JUpload',
    componentProps:{
     },
  },
  {
    label: '评审意见',
    field: 'reviewComments',
    component: 'InputTextArea',
  },
  {
    label: '状态',
    field: 'deleted',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "normalOrStop"
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  number: {title: '安全制度编码',order: 0,view: 'text', type: 'string',},
  version: {title: '版本号',order: 1,view: 'number', type: 'number',},
  name: {title: '安全制度名称',order: 2,view: 'text', type: 'string',},
  type: {title: '安全制度分类',order: 3,view: 'list', type: 'string',dictCode: 'safetySystemType',},
  subDepart: {title: '所属部门',order: 4,view: 'sel_depart', type: 'string',},
  releaseDate: {title: '发布日期',order: 5,view: 'date', type: 'string',},
  currentOrNot: {title: '是否现行',order: 6,view: 'radio', type: 'string',},
  startDate: {title: '启用日期',order: 7,view: 'date', type: 'string',},
  applicableDepart: {title: '适用部门',order: 8,view: 'sel_depart', type: 'string',},
  content: {title: '制度内容',order: 9,view: 'umeditor', type: 'string',},
  remarks: {title: '说明',order: 10,view: 'textarea', type: 'string',},
  doc: {title: '制度相关附件',order: 11,view: 'file', type: 'string',},
  organizer: {title: '编制人',order: 12,view: 'sel_user', type: 'string',},
  reviewDate: {title: '评审日期',order: 13,view: 'date', type: 'string',},
  assessor: {title: '评审人',order: 14,view: 'sel_user', type: 'string',},
  evaluator: {title: '参评人员',order: 15,view: 'sel_user', type: 'string',},
  reviewDoc: {title: '评审相关附件',order: 16,view: 'file', type: 'string',},
  reviewComments: {title: '评审意见',order: 17,view: 'textarea', type: 'string',},
  deleted: {title: '状态',order: 18,view: 'radio', type: 'string',},
};
